_require local "../../../../basis.smi"
(* _require local "../../../libs/env/main/SEnv.smi" *)
_require local "../../../data/symbols/main/RecordLabel.smi"
_require local "../../../extensions/debug/main/Bug.smi"
_require local "../../../libs/ids/main/LocalID.smi"

_require local "../../../data/builtin/main/BuiltinTypes.smi"
_require local "../../../data/runtimetypes/main/RuntimeTypes.ppg.smi"
_require local "../../../extensions/usererror/main/UserErrorUtils.smi"
_require local "../../../data/runtimetypes/main/DatatypeLayout.smi"
_require local "../../../data/types/main/Types.ppg.smi"
_require local "../../../data/types/main/TvarMap.smi"
_require local "../../../data/types/main/DynamicKindUtils.smi"
_require local "./NameEvalError.ppg.smi"
_require local "./NameEvalUtils.smi"
_require local "./NormalizeTy.smi"
_require local "./SetLiftedTys.smi"

_require "../../../data/symbols/main/Loc.smi"
_require "../../../data/symbols/main/Symbol.smi"
_require "../../../compilerIRs/absyn/main/AbsynTy.smi"
_require "../../../compilerIRs/idcalc/main/IDCalc.ppg.smi"
_require "../../../compilerIRs/patterncalc/main/PatternCalc.ppg.smi"
(* _require "../../../compilerIRs/patterncalc/main/PatternCalcInterface.ppg.smi" *)
_require "./NameEvalEnv.ppg.smi"
_require local "./NameEvalEnvPrims.smi"

structure EvalTy =
struct
  type tvarEnv = IDCalc.tvar SymbolEnv.map
  val emptyTvarEnv : tvarEnv
  val genTvar : tvarEnv -> AbsynTy.tvar -> tvarEnv * IDCalc.tvar
  val genTvarList : tvarEnv -> AbsynTy.tvar list -> tvarEnv * IDCalc.tvar list
  val evalTy : tvarEnv -> NameEvalEnv.env -> AbsynTy.ty -> IDCalc.ty
  val evalTyWithFlex : tvarEnv -> NameEvalEnv.env -> AbsynTy.ty -> IDCalc.ty
  val getProperty : tvarEnv -> NameEvalEnv.env -> AbsynTy.opaque_impl -> Loc.loc -> IDCalc.property
  val compatProperty : {abs:IDCalc.property, impl:IDCalc.property} -> bool
  val evalTvar : tvarEnv -> AbsynTy.tvar -> IDCalc.tvar
  val evalFfity : tvarEnv -> NameEvalEnv.env -> PatternCalc.ffiTy -> IDCalc.ffiTy
  val emptyScopedTvars : IDCalc.scopedTvars
  val evalScopedTvars : 
      tvarEnv 
      -> NameEvalEnv.env
      -> PatternCalc.scopedTvars
      -> tvarEnv * IDCalc.kindedTvar list
  val evalDatatype :
      Symbol.symbol list -> NameEvalEnv.env
                         -> PatternCalc.datbind list * Loc.loc
                         -> NameEvalEnv.env * IDCalc.icdecl list
  val resetFreeTvarEnv : unit -> unit
end
